package com.security.system.serviceImpl;

import com.security.system.dao.SysMenuDao;
import com.security.system.entity.SysUser;
import com.security.system.service.IndexService;
import com.security.utils.R;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class IndexServiceImpl implements IndexService {

    @Resource
    SysMenuDao dao;

    @Override
    public R getMenu(Authentication authentication) {
        SysUser user = (SysUser)authentication.getPrincipal();
        List<Map<String,Object>> contentManagement = dao.getMenu(user.getRoles().get(0).getRid().toString(),"contentManagement");
        List<Map<String,Object>> memberCenter = dao.getMenu(user.getRoles().get(0).getRid().toString(),"memberCenter");
        List<Map<String,Object>> systemeSttings = dao.getMenu(user.getRoles().get(0).getRid().toString(),"systemeSttings");
        List<Map<String,Object>> seraphApi = dao.getMenu(user.getRoles().get(0).getRid().toString(),"seraphApi");
        Map<String,Object> res = new HashMap<>();
        res.put("contentManagement",contentManagement);
        res.put("memberCenter",memberCenter);
        res.put("systemeSttings",systemeSttings);
        res.put("seraphApi",seraphApi);
        System.out.println(contentManagement);
        return R.success(res);
    }
}
